/* eslint-disable @typescript-eslint/no-empty-object-type */

// import axios from 'axios';
import { baseRequestClient, requestClient } from '#/api/request';

export namespace QctemplateApi {
  export interface QctemplateListParams {
    pageNum: number;
    pageSize: number;
  }
  export interface QctemplateindexListParams {
    pageNum: number;
    pageSize: number;
    templateId: null | number;
  }
  export interface Params {}
  export interface Row {
    searchValue: null;
    createBy: string;
    createTime: string;
    updateBy: string;
    updateTime: null | string;
    remark: string;
    params: Params;
    templateId: number;
    templateCode: string;
    templateName: string;
    qcTypes: string;
    qcTypesParam: string[];
    itemId: null;
    enableFlag: string;
    attr1: null;
    attr2: null;
    attr3: number;
    attr4: number;
  }
  export interface Row1 {
    searchValue: null;
    createBy: string;
    createTime: string;
    updateBy: string;
    updateTime: null;
    remark: string;
    params: Params;
    recordId: number;
    templateId: number;
    indexId: number;
    indexCode: string;
    indexName: string;
    indexType: string;
    qcTool: null | string;
    checkMethod: string;
    standerVal: null | number;
    unitOfMeasure: null | string;
    thresholdMax: number;
    thresholdMin: number;
    docUrl: null;
    attr1: null;
    attr2: null;
    attr3: number;
    attr4: number;
  }
  export interface Row2 {
    searchValue: null;
    createBy: string;
    createTime: string;
    updateBy: string;
    updateTime: null;
    remark: string;
    params: Params;
    recordId: number;
    templateId: number;
    itemId: number;
    itemCode: string;
    itemName: string;
    specification: string;
    unitOfMeasure: string;
    unitName: string;
    quantityCheck: number;
    quantityUnqualified: number;
    crRate: number;
    majRate: number;
    minRate: number;
    attr1: null;
    attr2: null;
    attr3: number;
    attr4: number;
  }
  export interface qctemplateListResult {
    total: number;
    rows: Row[];
    code: number;
    msg: string;
  }
  export interface qctemplateindexResult {
    total: number;
    rows: Row1[];
    code: number;
    msg: string;
  }
  export interface qctemplateproductResult {
    total: number;
    rows: Row2[];
    code: number;
    msg: string;
  }
}

// 获取质检方案列表
export const getQctemplateList = (data: QctemplateApi.QctemplateListParams) => {
  return requestClient.get<QctemplateApi.qctemplateindexResult>(
    '/mes/qc/qctemplate/list',
    { params: data },
  );
};
// 获取检测项列表
export const getQctemplateindexList = (
  data: QctemplateApi.QctemplateindexListParams,
) => {
  return requestClient.get<QctemplateApi.qctemplateListResult>(
    '/mes/qc/templateindex/list',
    { params: data },
  );
};
// 获取物料产品列表
export const getQctemplateproduct = (
  data: QctemplateApi.QctemplateindexListParams,
) => {
  return requestClient.get<QctemplateApi.qctemplateproductResult>(
    '/mes/qc/templateproduct/list',
    { params: data },
  );
};

// 增加缺陷
export const addQctemplate = (data: QctemplateApi.Row) =>
  requestClient.post<QctemplateApi.qctemplateListResult>(
    '/mes/qc/qctemplate',
    data,
  );
// 增加检测项
export const addQctemplateindex = (data: QctemplateApi.Row1) =>
  requestClient.post<QctemplateApi.qctemplateindexResult>(
    '/mes/qc/templateindex',
    data,
  );
// 增加物料产品
export const addQctemplateproduct = (data: QctemplateApi.Row2) =>
  requestClient.post<QctemplateApi.qctemplateproductResult>(
    '/mes/qc/templateproduct',
    data,
  );

// 删除缺陷
export const deleteQctemplate = (id: string) =>
  requestClient.delete<QctemplateApi.qctemplateListResult>(
    `/mes/qc/qctemplate/${id}`,
  );
// 删除检测项
export const deleteQctemplateindex = (id: string) =>
  requestClient.delete<QctemplateApi.qctemplateindexResult>(
    `/mes/qc/templateindex/${id}`,
  );
// 删除物料产品
export const deleteQctemplateproduct = (id: string) =>
  requestClient.delete<QctemplateApi.qctemplateproductResult>(
    `/mes/qc/templateproduct/${id}`,
  );

// 修改缺陷
export const updateQctemplate = (data: QctemplateApi.Row) =>
  requestClient.put<QctemplateApi.qctemplateListResult>(
    '/mes/qc/qctemplate',
    data,
  );
// 修改检测项
export const updateQctemplateindex = (data: QctemplateApi.Row1) =>
  requestClient.put<QctemplateApi.qctemplateindexResult>(
    '/mes/qc/templateindex',
    data,
  );
// 修改物料产品
export const updateQctemplateproduct = (data: QctemplateApi.Row2) =>
  requestClient.put<QctemplateApi.qctemplateproductResult>(
    '/mes/qc/templateproduct',
    data,
  );

// 获取自动生成编码
export const getQctemplateCode = () =>
  baseRequestClient.get<any>('/system/autocode/get/QC_TEMPLATE_CODE');
